<template>
	<view>
		<cu-custom bgColor="bg-black" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">店铺信息</block>
			<!-- <block slot="right">
				<view @tap="modelFlag = true;editFlag = false">添加</view>
			</block> -->
		</cu-custom>
		<view>
			<view class="cu-bar bg-white">
				<view class="action border-title">
					<text class="text-xl text-bold text-black">商铺信息</text>
					<text class="bg-gradual-red" style="width:3rem"></text>
				</view>
			</view>
			<form>
				<view class="cu-form-group">
					<view class="title">商铺名称</view>
					<input placeholder="请输入商铺名称" name="input"></input>
				</view>
				<view class="cu-form-group">
					<view class="title">店铺位置</view>
					<input placeholder="请输入店铺位置" name="input"></input>
					<text class='cuIcon-locationfill text-orange'></text>
				</view>
				<view class="cu-form-group">
					<view class="title">联系信息</view>
					<input placeholder="请输入联系信息" name="input"></input>
				</view>
				<view class="cu-form-group">
					<textarea maxlength="-1" placeholder="请输入商铺介绍"></textarea>
				</view>
				<view class="cu-form-group">
					<textarea maxlength="-1" placeholder="请输入商铺公告内容"></textarea>
				</view>
				<view class="cu-bar bg-white">
					<view class="action">
						商铺图片
					</view>
					<view class="action">
						{{imgList.length}}/4
					</view>
				</view>
				<view class="cu-form-group">
					<view class="grid col-4 grid-square flex-sub">
						<view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" :data-url="imgList[index]">
						 <image :src="imgList[index]" mode="aspectFill"></image>
							<view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
								<text class='cuIcon-close'></text>
							</view>
						</view>
						<view class="solids" @tap="ChooseImage" v-if="imgList.length<4">
							<text class='cuIcon-cameraadd'></text>
						</view>
					</view>
				</view>
			</form>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgList: [],
			}
		},
		methods: {
			ChooseImage() {
				uni.chooseImage({
					count: 4, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						if (this.imgList.length != 0) {
							this.imgList = this.imgList.concat(res.tempFilePaths)
						} else {
							this.imgList = res.tempFilePaths
						}
					}
				});
			},
			ViewImage(e) {
				uni.previewImage({
					urls: this.imgList,
					current: e.currentTarget.dataset.url
				});
			},
			DelImg(e) {
				uni.showModal({
					title: '召唤师',
					content: '确定要删除这段回忆吗？',
					cancelText: '再看看',
					confirmText: '再见',
					success: res => {
						if (res.confirm) {
							this.imgList.splice(e.currentTarget.dataset.index, 1)
						}
					}
				})
			}
		}
	}
</script>

<style>
	.cu-form-group .title {
		min-width: calc(4em + 15px);
	}
</style>
